import { View } from "react-native";
import { Stack, useLocalSearchParams } from "expo-router";
import BookmarkAssetImage from "@/components/bookmarks/BookmarkAssetImage";
import BookmarkTextMarkdown from "@/components/bookmarks/BookmarkTextMarkdown";
import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView";
import FullPageSpinner from "@/components/ui/FullPageSpinner";
import PageTitle from "@/components/ui/PageTitle";
import { api } from "@/lib/trpc";
import { BookmarkTypes, ZBookmark } from "@hoarder/shared/types/bookmarks";
function BookmarkTextView({ bookmark }: { bookmark: ZBookmark }) {
if (bookmark.content.type !== BookmarkTypes.TEXT) {
throw new Error("Wrong content type rendered");
}
const content = bookmark.content.text;
return (
);
}
function BookmarkAssetView({ bookmark }: { bookmark: ZBookmark }) {
if (bookmark.content.type !== BookmarkTypes.ASSET) {
throw new Error("Wrong content type rendered");
}
return (
);
}
export default function BookmarkView() {
const { slug } = useLocalSearchParams();
if (typeof slug !== "string") {
throw new Error("Unexpected param type");
}
const { data: bookmark } = api.bookmarks.getBookmark.useQuery({
bookmarkId: slug,
});
let comp;
let title = null;
if (bookmark) {
switch (bookmark.content.type) {
case BookmarkTypes.LINK:
comp = null;
break;
case BookmarkTypes.TEXT:
title = bookmark.title;
comp = ;
break;
case BookmarkTypes.ASSET:
title = bookmark.title ?? bookmark.content.fileName;
comp = ;
break;
}
} else {
comp = ;
}
return (
{comp}
);
}